import React,{useEffect} from 'react'
import {getTourlist} from '@/api/service'
import { useState } from 'react';
import { Radio, Space, Table, Tag } from 'antd';
import type { ColumnsType } from 'antd/es/table';
import {initTable} from '@/hoc/index'

import {useAddkey} from '@/hooks/index'








const columns = [
  {
    title: 'ID',
    dataIndex: 'vid',
    key: 'vid',
  },
  {
    title: '游客id',
    dataIndex: 'visitor_id',
    key: 'visitor_id',
  },
  {
    title: '游客名称',
    dataIndex: 'visitor_name',
    key: 'visitor_name',
  },
 
  {
    title: '游客头像',
    dataIndex: 'visitor_avatar',
    key: 'visitor_avatar',
    // http://fangadmin.shbwyz.com/static/common/images/visitor.jpg
    render:((item:any)=>{
      return <img style={{width:50,height:50}} src={`http://fangadmin.shbwyz.com${item}`} alt="" />
    })
  },
  {
    title: '在线状态',
    dataIndex: 'online_status',
    key: 'online_status',
    render:((item:any)=>{
     return <span>
      {item === 1?<Tag color='#099'>在线</Tag>:<Tag color='#776'>离线</Tag>}
     </span>
    })
  },
  {
    title: 'IP',
    dataIndex: 'visitor_ip',
    key: 'visitor_ip',
  },
  {
    title: '创建时间',
    dataIndex: 'create_time',
    key: 'create_time',
  },
];



 function index(props:any) {
//  const [data,setData] = useState([])
//   const [total,setTotal] = useState(1)
//   useEffect(()=>{
//     getTourlist().then((res)=>{
//       console.log(res.data,'res')
//       setData(useAddkey(res.data.data))
//       setTotal(res.data.count)
//     })
//   },[])
console.log(props)
  return (
    <div>
      {/* 游客列表http://fangadmin.shbwyz.com/visitorList?page=1&limit=20 */}
      
      {/* rowKey="vid" */}
      {/* <Table columns={columns}  pagination={{ total,
        pageSize:5,pageSizeOptions:[1,2,3,4,5,6],
        showQuickJumper:true,
        }} dataSource={data} /> */}
        <Table rowKey="vid" columns={columns} dataSource={props.data} />

    </div>
  )
}

export default initTable(getTourlist)(index)